<?php
require_once("Interfaces/Controllable.php");
class Ciudadano implements Controllable{
    public $idCiudadanos;
    public $CURP;
    public $Nombres;
    public $ApellidoPaterno;
    public $ApellidoMaterno;
    public $Edad;
    public $Sexo;
    public $Municipio;
    
    public function __construct($idCiudadanos='',$CURP='',$Nombres='',$ApellidoPaterno='',$ApellidoMaterno='',$Edad='',$Sexo='',$Municipios_idMunicipios=''){
        $this->idCiudadanos = $idCiudadanos;
        $this->CURP = $CURP;
        $this->Nombres = $Nombres;
        $this->ApellidoPaterno = $ApellidoPaterno;
        $this->ApellidoMaterno = $ApellidoMaterno;
        $this->Edad = $Edad;
        $this->Sexo = $Sexo;
        $this->Municipios_idMunicipios = $Municipios_idMunicipios;
    }
    function asControl($controlTag , $selected = false){
        $retVal = "";
        if($controlTag == 'FORM'){
            $retVal .= "<input type='hidden' name='idCiudadanos' id='idCiudadanos' value='$this->idCiudadanos'>\n";
            $retVal .= "<br/><span>CURP</span><br/>\n";
            $retVal .= "<input type='text' name='CURP' id='CURP' value='$this->CURP'><br/>";
            $retVal .= "<br/><span>Municipio</span><br/>\n";
            $muns = new Municipios();
            $muns->loadAllFromDB();
            $retVal .= $muns->asSelect()."<BR/>";
            $retVal .= "<span>Nombre(s)</span><br/>\n";
            $retVal .= "<input type='text' name='Nombres' id='Nombres' value='$this->Nombres'><br/>";
            $retVal .= "<span>Apellido paterno</span><br/>\n";
            $retVal .= "<input type='text' name='ApellidoPaterno' id='ApellidoPaterno' value='$this->ApellidoPaterno'><br/>";
            $retVal .= "<span>Apellido materno</span><br/>\n";
            $retVal .= "<input type='text' name='ApellidoMaterno' id='ApellidoMaterno' value='$this->ApellidoMaterno'><br/>";
            $retVal .= "<span>Edad</span><br/>\n";
            $retVal .= "<input type='text' name='Edad' id='Edad' value='$this->Edad'><br/>";
            $retVal .= "<span>Sexo</span><br/>\n";
            $selected = $this->Sexo;
           $retVal .= "<SELECT type='text' name='Sexo' id='Sexo'><option value='M' ".($selected=='M'?"selected='selected'":"").">M</option><option value='F' ".($selected=='F'?"selected='selected'":"").">F</option></select><br/>";
        }
        if($controlTag == 'DIV'){
            $retVal .= "<div>\n";
            $retVal .= "<input type='hidden' name='idCiudadanos' id='idCiudadanos' value='$this->idCiudadanos'>\n";
            $retVal .= "<span>CURP</span><br/>\n";
            $retVal .= "<input type='text' name='CURP' id='CURP' value='$this->CURP'><br/>";
            $retVal .= "<span>Nombre(s)</span><br/>\n";
            $retVal .= "<input type='text' name='Nombres' id='Nombres' value='$this->Nombres'><br/>";
            $retVal .= "<span>Apellido paterno</span><br/>\n";
            $retVal .= "<input type='text' name='ApellidoPaterno' id='ApellidoPaterno' value='$this->ApellidoPaterno'><br/>";
            $retVal .= "<span>Apellido materno</span><br/>\n";
            $retVal .= "<input type='text' name='ApellidoMaterno' id='ApellidoMaterno' value='$this->ApellidoMaterno'><br/>";
            $retVal .= "<span>Edad</span><br/>\n";
            $retVal .= "<input type='text' name='Edad' id='Edad' value='$this->Edad'><br/>";
            $retVal .= "<span>Sexo</span><br/>\n";
            $retVal .= "<SELECT type='text' name='Sexo' id='Sexo'><option value='M'></option></select><br/>";
            $retVal .= "</div>\n";
        }
        return $retVal;
    }
}
?>